
const tokens = {
  admin: {
    token: 'admin-token'
  }
}

const users = {
  'admin-token': {
    username: 'admin',
    name: 'admin-name',
    avatar: 'https://img-blog.csdnimg.cn/2020121817131659.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyMTc4Mzkx,size_16,color_FFFFFF,t_70#pic_center',
    introduction: 'vue-next-element-plus-admin搭建测试',
    roles: ['admin']
  }
}

module.exports = [
  {
    url: '/vue-next-element-plus-admin/user/login',
    type: 'post',
    response: config => {
      const { username } = config.body
      const token = tokens[username]
      if (!token) {
        return {
          code: 60204,
          message: '该账号不存在'
        }
      }
      return {
        code: 20000,
        data: token,
        message: '登录成功'
      }
    }
  },
  {
    url: '/vue-next-element-plus-admin/user/get-userinfo\.*',
    type: 'get',
    response: config => {
      const { token } = config.query
      const info = users[token]
      if (!info) {
        return {
          code: 50000,
          data: {},
          message: '该用户不存在'
        }
      }
      return {
        code: 20000,
        data: info,
        message: '用户信息获取成功'
      }
    }
  }
]
